//
//  NetWorkState.m
//  开眼
//
//  Created by 教主 on 15/11/3.
//  Copyright © 2015年 教主. All rights reserved.
//

#import "NetWorkState.h"
#import "Reachability.h"

@implementation NetWorkState
+ (NetWorkState *)shareInstance
{
    static NetWorkState *state = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        state = [[NetWorkState alloc] init];
    });
    return state;
}

// 判断网络是否正常
- (BOOL)reachability
{
    Reachability *r = [Reachability reachabilityWithHostName:@"www.baidu.com"];
    switch ([r currentReachabilityStatus]) {
        case ReachableViaWiFi:
            return YES;
            break;
        case ReachableViaWWAN:
            return YES;
            break;
        case NotReachable:
            // 弹出视图
            return NO;
            break;
        default:
            break;
    }
}
@end
